package com.ldf.jrtsp.task;

import com.ldf.jrtsp.enums.RtspOptionsType;
import com.ldf.jrtsp.player.RtspPlayer;

import java.util.List;
import java.util.TimerTask;

/**
 * rtsp保活任务
 *
 * @author lidaofu
 * @since 2024/6/26
 **/
public class RtspKeepAliveTask extends TimerTask {
    private final RtspPlayer rtspPlayer;

    public RtspKeepAliveTask(RtspPlayer rtspPlayer) {
        this.rtspPlayer = rtspPlayer;
    }

    @Override
    public void run() {
        List<String> options = rtspPlayer.getOptions();
        if (options != null && options.contains(RtspOptionsType.GET_PARAMETER.name())) {
            rtspPlayer.sendGetParameter();
        } else {
            rtspPlayer.sendOptions();
        }
    }
}
